<?php

$client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);
$client->on("connect", function($client) {
    $client->send("hello\n");
});
$client->on("receive", function($client, $data) {
    echo "data: $data";
});
$client->on("error", function($client) {
    echo "失败\n";
});
$client->on("close", function($client) {
    echo "关闭\n";
});
$client->connect("localhost", 8080, 10);